Finished optimized decoding code (for now)