Do not call get_unique_id if not needed.

get_unique_id can cause a performance overhead, so only call
if neeeded.
Merge pull request #29 from aptivate/only_get_id_if_necessary

Do not call get_unique_id if not needed.