Some bug fixes, plus some test classes done