add docs, improve API