Cleaned up logic for connecting trace database to model and sampling based on whether sampling has already been run.