Updated with full code, missing html fixes