Refactor application kind Also clean up routing logic a little