Perception, decision making, and movement are enhanced by cortical circuitry, which has a stereotyped architecture repeated across the entire surface of the brain. In this talk, I will discuss our investigations of how the different cortical layers contribute to behavior. I will show how modern optogenetic and traditional lesion manipulations can lead to opposing conclusions about the necessity of a brain structure, layer, or cell type. We have developed novel cortex-dependent tasks for the rodent whisker system in which we manipulate and record the layers to test their functions. By combining array recordings and modeling in these tasks, we are additionally able to disentangle the contributions of sensory, motor, choice, and reward signals to the activity of individual neurons. We find that task context can reweight this mixture so dramatically that even somatotopic organization disappears. Imaging of apical tuft dendrites suggests that layer 1 may be a substrate by which learning reconfigures sensory cortex according to task context.