refactoring, fixes.. all decoder tests passed!