Refactored NBT decoder.