General refactoring of code and scripts.