Describe a time you had to refactor a research-grade script into production-ready code for an AI system. What steps did you take?