Fix for redirect loop and back button (fixed issue #11)