Fix bugs introduced in last commit