Improve comments and code formatting
Refactor hn slightly