More edits, mostly to script.js

Still not running, improved at least. All around bug fixes. Might have
to restructure the boundary detection and removal procedure.