did some cleanup
major refactoring