Minor refactoring and updated some deprecated code