Fix some outstanding bugs