Remove debug and whitespace changes
Simplify if/else logic

Removes some unnecessary nesting and converts to else if where possible
pre_replace() to str_replace() for performance
Use http class to perform redirects
$engine->cleanGet to $_GET