Fix static interface to dynamic program

Fixed several memory issues and removed redundant containers for segment loss