Move quick folding code

Signed-off-by: Yen-Chin Lee <coldnew.tw@gmail.com>