Use data.table for faster operations.
Improve centering function.