Major refactor, introducing class system and separating classes into files