Merge new code from James into theano_linear / theano_linear cleanup