Mostly done transmitter code