Bug fixes and added an output buffer size option