You mentioned missing verbal instructions at school and "selective hearing" at home. This can be a symptom of ADHD or it can be a symptom of poor auditory processing. I might look into a full audiology exam (not a hearing test at the regular pediatrician).

Are the structured settings, like the math class, also freer from background noise, and does the teacher there speak more clearly, or at a higher volume? Are there more visual cues in some classes then in others? What is the level of routine like in the different classes? How much decision making is required in each environment?(Is seating assigned? Does the work require choosing topics, or are they assigned?) How is the seating organized? Analyzing the environments and situations where he does well and comparing and contrasting them with environments where he does poorly can give you clues to what he is really having difficulty with.

I might also look into having his sensory integration evaluated, since you have noticed a high degree of sensory sensitivity. It is possible that the school is a more annoying and distracting sensory environment than home is, and this is part of why he is having trouble paying attention there.

Disorganization in school work could just be because he doesn't have a system. "Late, Lost, and Unprepared" and "Smart, but Scattered" are two great resources for helping build executive function skills (like time management, organization, impulse control, etc.), and you might find them helpful.

You haven't mentioned any social difficulties, but you may want to be sure that Asperger's is ruled out. The disorganization around school, the uneven performance across assignments and domains, the willingness to challenge authority, and the sensory issues are all little flags. Great motor skills makes me lean away from this, but I'd feel awful if I didn't at least mention the possibility if this is actually what is going on.

I'd make sure that any professional you took him to to evaluate this possibility was familiar with both gifted kids and kids on the spectrum and with how gifted kids on the spectrum manifest, so that they don't confuse the two or miss one thinking it is all the other.

And while you are investigating those things, I'd look into getting him more challenge in the classes where he daydreams and looks around the room...whether it is gifted underachievement or ADHD (which it doesn't really sound like), or even being insulted and bored by the level of the work, increasing the challenge level so that the work captures attention and holds interest can help dramatically.