Process intensification and process control in freeze-drying