Refactored the whole system to be more object-oriented