Yamaha F150 Starting Problem

I posted about this same issue back in March - thought I fixed it with with a new battery switch after getting advice from Chas Marine but the problem happened again this weekend and had to use my Sea Tow membership for the first time. I have a 2005 Yamaha F150 - the problem is that the both the starter and the trim “click” as if the batteries are dead. The engine started fine, and then when throttling up to get on plane it just died as if I hit the kill switch. Went to restart and just the clicking noise. Same clicking noise with the trim. All of the other electronics still worked fine and the volt meter was showing 12.5V. Sea Tow brought me back to the dock. Once back, we hooked up some jumper cables to the starting battery - it gave enough juice to tilt the engine up in order to get it on the trailer but the engine still wouldnt turn over. I figured I needed new batteries. I have a dual battery set up - one battery is from 2005 and one is from 2007 so I went ahead and replaced them with an Optima Blue Top starting battery as #1 and a deep cycle battery as #2. Figured the engine would fire right up - but same problem - new batteries didnt fix it. Then I took a wire brush to all my battery cables until they were nice and shiny - this didnt fix it either. Then I took the engine cover off and started tickering around. I unplugged the main engine control wire connector and then plugged it back in. The engine fired right up and the trim worked again! I let the engine run for a while at different rpms and then shut it off and and restatred it a few times. Then on about the 3rd of 4th try I got the same clicking again. I tried disconnecting the engine conrol wire connector again and plugged it back in - still got the clicking noise and have been unable to restart the engine since then. I hooked up some jumper cables again to the new optima just to do a sanity check and it still wouldn’t start. Any ideas?

Thanks