major refactor to eliminate unnecessary socket and threading