Refactor html_generator.rb and router.rb