Removed unused varabiles, added some documentation.