Add some comments
Refactor a bit of code, improve comments, and add a TODO. No functional changes.