fixes and tweaks to the redirect functionality