special handling for square terms

Fixes #308. This only works on 0.4. Not sure if there's a good non-invasive solution for 0.3.