File loading revised to allocate and free header memory. Code reorganized. Image freeing completed