Added pair fix and varius bug fixes