Add hostname checking

Also remove some trailing whitespace