Fixed lots of bugs, added database driver function prototypes