Factored out some internal classes.  Added (unfinished) collections implementation.