Added cache functionallity.
Comments added.
Clean up.