Significant changes made to reduce memory usage.  There were many redundant arrays and unnecessary copies of arrays