added comments and some small fixes