Several bugfix from Issue #1 and update documentation