Fixed crashing errors