refactored module structure and fixed ip address autodetect