Fixed emitting error when redirecting, fixed options being undefined in some cases