fix bugs in new frame-based logic