Refactored and improved qsub generator