Some fixes

Note: 7a81df0 makes it again possible to write output to file.