Fixed misunderstanding of pairs and ipairs
Further fixed issues with pair and ipairs and fixed a bug that prevented ejection of excess compounds. Also reactivated AI.