Check the TRE connection, as Tall says, they sit on the pink wire to tell the ECU the bike is always in 4th, some also let through the neutral voltage from what I have read.
If you are getting intermittent errors with the gear position sensor then your TRE might have a loose connection, either in the connectors or one the internal components, which looks like it can range from a single resistor or a couple of resistors and a transistor.
If it was fine before, try remove the TRE and if it is fine again, put it back in, if the problem is still there, return it.