Cleaned up panic code