Restructured and reworked the Database classes

Signed-off-by: Christian Neff <christian.neff@gmail.com>