Fixes #381 and #508

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.