handle cases to avoid multiple generation of global objects

Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
comments and cleanup

Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>