Fixed hostname checking logic and added %code for ip tip.