Improve ip handling