python wrapper cleanup