handle external edits; fix a few bugs; code cleanup