Improved panic handling