merged with Yi-cheng's HTML5 work