Fixed Nullpointer Exceptions