Fixed some minor bugs in code at home, needs further testing at the lab