There is room for optimizing the handler's algorithm. See here. As applicable, these should also be ported back into machine.py.