Changed current_doc to cur_doc
Fixed memory leak by option