Bug fix and add documentation.