rebased on metadata, improved docs