Fix #986 and improve documentation.