Refactor due to language changes, and deprecation warnings