Fix some scan bugs