branch-related code cleanups + some e2e tests for branch