Fixed a number of issues with errors