Added improved form handling - restores original values if changes are cancelled