Fix previous commit which introduced two bugs