Several fixes

Please check the complete commit descriptions (they usually show up after you press the "..." button next to each of the commit summaries).

Please make sure to review all the changes before accepting the pull request.

Thanks.

P.S: There is a spurious "(not really expected)" by the end of the "Fixed output filenames" commit description. Please ignore it, since I actually think this result is somehow more expected than the former behavior. The error in the description was due to copy&paste.