more typed decoder. Fixed bugs