Fix bugs in last commit