fixed some template issues and flask redirects