Cleanup and finish header building function. Add main page as always there.