Updated server module to better handle environment and port passed via commandline.