Updated errors function to handle device 0 better. Has code for future cleanup as well