More refactoring and removing crap code