Refactored a lot!