Changing occurrences of localhost (ports 3000/4000) and refactor them to use the config files