More documentation and small optimizations.