remove old version; some refactoring; cleanup