Fixed flushBuffer() function + changed pre-fill code to better match the older versions.