further tinkering and cleanup