Improve database loading and error handling