Actually use the prefer_xx() code

And fix some bugs and test