Fixed #297 by redoing the change from #273