Fix js timing bugs