Major refactoring

Old code was getting cluttered