Fixed crashing and Logging