Fix for bug #3056

Also added support for host aliases and re-worked duplicate entry handling so it's more robust
Merge pull request #465 from plinss/master

Fix for bug #3056