Fix some bugs from last commit