Removed some dead code, and added/modified some comments