Fix uses of deprecated stuff
Refactoring