First attempt at decode.py
Improved decode.py