Do you always push the code to the device without testing the code in debug mode?
I would recommend to debug (you do not need to set breakpoints) all code first just to verify it, and if the code "brick" the device, just reboot it and it's back to normal.