Major overhaul of scanning engine