I don't know why, but the performance of the message handler has improved a little bit since I removed the 1s delay I had before (not in this code but in other places).