Remove duplication from generated subexpressions
Include line info in compiler thrown exceptions

Fixes #636