Further optimization, formatting fixes to reverse loops, revised API docs.