Optimise threading.