Adding the Configure Database script and fixing some bugs