Finish reimplementing rescan() function

Also currently untested