Added comments and fixed formatting.