Fix bugs found when testing in jquery-turtle.