Improve and optimize inet functions