Tweaked db stuff and started functional