[#895] Close connections in datastore when we don't need them any more. Also make sure that transactions variables are in current context.
Merge branch '895-close-datastore-connections'