Fixed a couple of crashes