* Added more checks for return values and null pointers. * Removed some dead code and unused variables. * Fixed handling of calls to exec() family functions. If this functions fail we need to cleanup resources.