More bugfixes.

I think I finally fixed the random freezing issue, which turned
out to be caused by a bug deep down in the code that interfaces
with the serial port. Also made freezing and unfreezing not break
the web dashboard.