Major refactoring, tests, changes, etc