add late import and fix closure error

Avoids a circular import and fixes an error with closure handling.
Assignments like this (and like `point = {}` below) cause Python to treat the variable as a local instead of using a closure. Clearing the objects instead of replacing them prevents an `UnboundLocalError`.