added comments
*greatly* environment handling, not fully tested though