Refactoring database access

Not quite ready for prime time...
Get all studies ported to compatible format

Need to clean up the rest of the data functions, but so far, so good...
Refactored data modules to work better

Refactored the calling conventions to work better with internal calls
for data.