Faster opt

This PR speed up Theano optimization.