Added some more error handling to hopefully find the bug that causes the serial monitor to freeze sometimes