Add enablePreframe method and optimize a bit.