hostname attribute issue & indentation

Better fix for hostname attribute issue, and some indentation fixes.