mostly spec compliant, i think