Performance improvement.

Internal storage of IDs and pids is changed to hash set (ets based).