Issue #286 Add documentation and fix code