Fix up some stuff to make the code more spec compliant
Merge pull request #19 from ehsan/spec-compliance

Fix up some stuff to make the code more spec compliant