Moved (back) error and console redirection to start of JS code.
Added comments about error- and console redirection.