cleaned up memory allocation for path layers