Architecture redesign

This is mainly a redesign of the architecture with the end-goal of having a more maintanable project. I've modified quite a number of things (see the commit message) so any and all feedback is welcome.