Fixed stdout/stderr redirection bug