added main==null check to prevent running reflection on tick