Tons of debugging stuff to try and pinpoint the cause of the crashing