immutable references and a pluggable ref database

Hey let's make references immutable.  Also back them by some configurable database.