fixed a numerous bugs in the script related to the single inst case
Fixed multi-instance related bugs in the generated init script
Fixed another bug in the generated init script