Initial commit of library code.  Seems to work.