fix possible memoryt leak
add useful enum
 master branch merge from PR2