[major] code fixes, move optimize to pagelets