Fixed bugs from previous commit