Fidling with DB managmeent

Added some better controls and worked out some IO issues. Still work in
progress.