Added support in document details saving

Not yet functional, fixed few bugs Alex found.