Improved error support and added extra routines