Added comments and small bugfix