added SIGTERM catching, better command running, better exception handling