cleans up; next step: port code from previous versions