Fixed bugs and previously commented away code