Important bug fixes

Now correctly grabs IDs from treeViews, various bug fixes, redone file
writing and deleting mechanism.