Faster opt

This also clean up code.