Fixed some NullpointerException

Still more to go