Fixed buffer handling bug
Added documentation and example