minor refactor, still very C'ish
Tweaks to the reference implementation
Reference isn't needed anymore