fix and simplify tx serialization