add late import and fix closure error

Avoids a circular import and fixes an error with closure handling.