added db script and some fixes