Reordering initialization to avoid NullPointerExceptions