fixed most of the crashes now to try and fix a load of bugs