Fixed bugs caused by regression