Optimized sample loading using factory (thanks to olostan)