Fixes to have code not throwing random fatal errors.