Improved error codes/handling