Replace chain_id with chain.id a few places.
get_chain_by_id, get_chain_by_name: new public methods.
Switch from dicts to Chain objects.