Fixed errors caused by refactoring