Fixed some issues found by Peter Luschny on MSVC.