general edits to extremely old/slow code