Initial working version of analysis / processing logic