Cleaning up code, got decoder to work