Refactoring and work on legacy 1.x stuff