redirect bugfix, optimizations