fixed adding/removing entries via js

I discovered two problems with the js:
First the indexes were wrong after adding/removing entries.
Second the entries were added/removed without the containing div.

I hope the fix is fine enough...