This is the first non-WIP version of this series. It adds a small optimization (something like a 10% speedup on SSD), and some documentation and tests.