Fixed NullPointerExceptions