macosx: remove unneeded containsObject calls, fix UInt underflow, fix array cleaning