tons of refactoring and neatening of code