Lot's of refactoring