Added buffer writing functionality.