refactoring, comments, general cleanup