validate:valid_ip fixed, other code clanup