reorganized, updated docs, added error callback