Upgraded server script

Modularized code
Skeleton to run scripts