Correctly handle functions that return nil or bools (fixes #245)