Integrability and limit cycles via first integrals