So much of what you wrote could have described my DS at that age. We found the book "The Explosive Child" to be a life saver for our situation. It really helped deal with a very intense kid. Even for our non-explosive kid I found it really useful.

For the homework piece I'd recommend doing some experiments to see if you can figure out a pattern. See what happens if you separate the writing part out by seeing if scribing the homework for him. See if it is mostly math related, or maybe just easy math but harder math is no problem or mostly coloring small picture related or whatever other pattern you can figure out. Keep in mind that many smart kids are very good at compensating for their weaknesses and hide them well. They also might be able to do it some times but it takes so much effort that it is hard for them to consistently repeat those results.

Hopefully testing will help you get some answers. I know for us it was a huge eyeopener and helped a lot.