Minor optimizations.
Improve const correctness.
Update TODO a bit.