Improved error reporting and fixed the last const qualifiers.