Fixed some NullPointerExceptions