Fix issue 245. If we open files to create a bookmark we should close
them again afterwards.
Some integration work
Some more work