Update comments.
Cleaned code a bit.
Added a test.