fixes minor bugs, formats code