Flash previous URL to session at the end of each request.
Use referer header if it exists.
Remove previous URL stuff from session. Bad idea.
Fixed potential logical issues
Fix conflicts.