made changes to work with outside server. Also cleaned up code