Major refactoring

* Separate bits which use wai-app-static from bits which don't
* Split code into modules