Cpp standalone improvements

This branch closes #187, #152, #213.

Tests passing on Windows, but since there are quite a few changes it could probably do with some review before merging.