I just went through something similar. In my case the battery moving around bent the contact points in the battery in a way that made the connection fragile. RIB alignment, foam pads from the Trek service bulletin and a new battery under warranty and it’s better than ever.