Cleaned up memory allocation and fragment allocation to reuse code instead of duplicating functionality across mulitple methods.
Cleaned up memory allocation and fragment allocation to reuse code instead of
duplicating functionality across mulitple methods.

tsg-/pyeclib,tsg-/pyeclib,tsg-/pyeclib