Refactoring and removing deprecated functions