Fix a couple crashes
Remove unused code.