Added flushing of the buffer. Changed the return values of a few functions to void, as they don't return anything meaningful.