Refactor tree html generation to make it a bit easier to expand on