Code improvements and deprecation fixes