Major restructuring and firefox support