The branch refractoring

With this commit all reference to the database is removed from the branch implementation. There was some refracting doing with the fetch leaf method due to accessibility.
It might be nice to convert this to a for loop instead so we get index out of bounds if the tag value ever is missing.