Fixing #15. Includes changes proposed by evansolomon.