added specialization and type check for ksClassInstance::getCppInstance()
various changes