Beautification.

Add comments.
Move some static methods to belong to their respective classes.