Fixed some outstanding bugs