Added environment aware initialization to work as CommonJS, AMD and global module