Variable slaughter

Got rid of most of the global variables in favor of per-device
variables.

Fixed the type-ing of the per-device variables.