modifications for Windows + VS2010
(includes &buffer[0] access fix when buffer.size=0)
tested on Windows 7