Small refactoring, fix bug #2, change docs.