Refactored, well, almost everything