First set of performance optimizations suggested by the use of cachegrind.
Some amendments.
A small change - making the user call assign_dofs if he does custom space adjustments.