Synchronize listeners

Java's synchronized blocks are reetrant, so it wasn't possible to
unsubscribe from handler. This patch uses CopyOnWriteArrayList that
makes it possible to remove listeners while iterating over a list.