Bug fixes - fix crashes on NULL values