Fixing bugs after refactor.