refactoring, reorganization, unit tests