bunch of additional features implemented
fixed buggy logic for flagging