Correct global heap pruning routine, rename some files, organize subroutines