Cleanup code
Add option parameter to sample loading function