Discrete optimization.

Making engine run faster, might have introduced new bugs.