Improved HTML generation