Fixed bugs introduced in last commit