Adds Redirect functionality and improves error handling