I think `packageName` as `Option` will also shorten some lines: `val packageName = t1 flatMap ...` and again `packageName foreach ...` instead of null check.