Fix a bug with getReplyRedirect function
Some code cleanup