Alot of refactoring