code cleanup, small refactoring, adding comments, removing deprecated references