Improved error reporting; Fixed prepared queries