Issue fixes

Fixes for issues 1 and 2. Not yet tested with VS2012.