Issue125

Fixes the most pressing parts of #125.

Needs testing on Windows - if that works, it can be merged into master.