Make the STM part a bit more readable
Fix packet length calculation when there is only one byte left in a packet
Pass resource ID to serializer