cleanup, refactor, integration tests