Sketch: move logic around to try to prevent hangup