Complete rewrite of import detection expressions