Added more logging and fixed redirection