Added shutdownhook and command redirection.