Added some comments.
Added lots of explicit return statements.