More bug fixes

Fixing some nil checks