added documentation and (hopefully) flexibility to the API