Fixed a bunch of crash bugs