Added comments and did a big change to the API. Untested, but will do further testing shortly.