New identifyForm function

Based on code from @axel-angel but rewritten in a more lightweight
style (IMHO, at least :).

Fixes #649.