Some optimizations and a bit of doc.