Add documentation and fix prefix matching