Fix variable reference
Handle class definitions when checking loops