Refactored the code and split everything into smaller and independent objects