Better /etc/hosts flattening and bug fixes