modify to use single file as much as possible
update comments, start API documentation as slim template.