Refactor more of the avalon.app module