Remove global scope assumptions in lib and exec code in non global scope

Change-Id: Ie506bafc661111932b15d3d3d4c03b3d3127806d
Merge "Remove global scope assumptions in lib and exec code in non global scope"