sites, ports and hosts sorting now working

minor refactoring of code to make it easier to maintain. some duplicate
code removed. css removed from js to make it easier to maintain