Added threading support and fixed a potential bug with the serial writing. Baud rate also halved.