Added protection from null in some methods