More testing and minor refactoring