Simplify things by placing the server wrap code into it's own function in the main script. Move to predominantly lowercase and local variables. Introduce usage of separate config files for each server.