Fixes potential undefined exceptions.