Only upgrade branch packages if required and never upgrade the same package twice. Fixes #118.