fixed the refine bugs; documentation
Merge branch 'NAG' of github.com:antonleykin/M2 into NAG

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
debug flag