Make symlink swapping atomical

See issue #333