Fixed some bugs introduced on last commit