Fixes CmsDB so it correctly read and close form the database