Fixes  #214 Adding some null checks