Solve several minor bugs in fringe cases