Do general refactoring to improve code quality. ~~It would be good to migrate to Typescript eventually (I'm crossing this out as not planned, unless someone really wants to :P)~~