Outsourced some pre-analysis code to a function.