Emulsification and demulsification related to crude oil production