Moved all decoding stuff to separate class