fixed a few bugs with db support