changes to facilitate scanning

scanning works, still a few minor bugs with it