Added comments to clarify code and correct name spaces.