Added comments everywhere and cleaned up mongo cursor