extend constant propagation to arbitrary pure expressions, fix bugs in optimizer