Fixed a threading related issue that occurs because $1 is not thread-safe when used from lambdas

See #29. I must admit that I cannot promise 100% equivalence between my approach and the original one. But all specs pass with these changes also, so I guess they cannot be **that** bad... :smiley: