Migrate analysis code into package