many minor changes
major restructuring of the database class, fixed serializing/deserializing