Finished decoding (untested). We seem to have a malloc corruption in the generate_encoding recursion :(, no time to find the issue atm.