Replaced anonymous functions with named functions. Fixes #17