Fixed gcc warnings and added error handling to shell escape