Ported the remaining conditions code