Refactor transaction class

This is actually what I consider a potential bug on BufferReader, so I left it here to detect when it is used and try to eliminate this strange behaviour.