Refactoring of decoding.cpp