- compatibility with R 3.x (mostly explicitly including libraries)
- replaced dcast calls with calls to custom function because dcast crashed (int overflow) with large tables