Refactored a lot of things