Fixed outstanding bugs