BUGFIX: Fixed Mem Leaks in 2d segmentation