Added event handler for button clicking, can now purchase upgrades, performed additional refactoring.