Updated with evolving code.