Refactoring of functions complete. Starting of instances done only if necessary. Also, ip addresses retrieved inline and not separately for efficiency.