Fix a NPE in certain callback cases. Add a couple of useful and predefined functions.
Merge pull request #28 from manolo/master