Fix some bugs caused by #172.