Fix compiler warnings

also fixes reused rnd random generator
Convert to State Monad

Use simpler, monadic sendMessage to transmit