Add ability to get a ref and pass default value.

This is most needed for the case where some refs may be optional.
Now the user can pass a 'false' to the ref lookup and get false back
instead of triggering a console error and an undefined result.