Bug fix and documentation