Start work on error handling

Some errors are now being dealt with and logged.