Fix typo in stats computation
Fix intellij warnings
Support scalar functions with @Nullable arguments