fix bugs, and prepare database settings

Signed-off-by: Eric <erich@xaos-ia.com>