Fixes for NULL handling