clear mask on extracted object, added lots of comments, code cleanup