Refactor code to add compatibility to e10s