Removed deprecated code, added a script, some refactoring