Made code slightly safer, changed the way I initialize some minor vectors and matrices that would sometimes cause crashes.