Fixes
Fixed schema redefinition and db close problem