Added decode/encode functions