Fixed bugs introduced by clean up