massive refactoring
continued cleanup