Fixes minor bugs/cleans up code