Optimization changes for Scan + added offset support and test cases + ch...

...anged preprocessor definition