cleanup to allow stateful api