Using the data.table library for significant speedup.
data.table changes for plot2.