changes to support decoding stage
merged old with new branch