Refactor almost everything to be pseudo-OOP and actually work correctly