Components cached in shared_ptr

Switched component cache to usage of share_ptr, to ensure memory
allocated by components is freed again.