cleaned up the organization a bit and added comments