Fixed incorrect method call.
Refactored common code to ClassComponent class.