Few updates. Added a check if script is running as extension.