Fix up some stuff to make the code more spec compliant