Make collection access thread safe in Class

Collection access in Class was not thread safe. This patch wraps collection access in locks so that lookups triggered by other threads (such as notifications) do not corrupt state.

This seems to correct some of the issues I was encountering in the StillMotion sample.