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.