Tidy up MathLib::isInt() - using a state machine approach