fix typo and document remaining functions; add proper 'length' function