Improved database loading and error handling