Improved stdout and stderr parsing