cleanup main, rewrite routes so they can be wrapped with middleware quickly and easily