1) made native process invocation handling more robust
2) some refactoring