internal: some more changes
internal: fix bug in swap function

Up until now tmp pointer contained reference to a's content, not the
content itself.