Finally fixed all NullPointerExceptions