Small tweeks to handle NullPointers