Improved null handling