Fix bugs caused by previous bugfix