Fixing some NullPointer Exceptions