Added comments and unit tests.
Tmp.