Minor Bugfixes and removed erroneous compiler warnings

This should work correctly. Just a warning, don't use the VS Git interface to commit, use the Github GUI, the VS interface will commit with different formatting and screw things up (so ignore the first two commits).