Fixed a few minor crashes