Final update to scanner sketch for slight performance boost. Draft version cooked.