Some extra bugs fixed and cleaning up