Fixes to crash