A few fixes to stop this from crashing.