Added some documentation, and found some places for improvement.