Improvements to load data script.

Also removed unused code.