[Manual merge of PR #512 - kg]
  Fixes #381 and #508
  Adding support for Generic Closures.  Not the best implementation, but
  fixes the issues.  There might be a better more comprehensive
  implementation around closures at a later point.