Use a binary instead of a linear search in findChild and containsPositionImmediate
Minor simplifications