public function getChangedFields($databaseFieldsOnly = false, $changeLevel = self::CHANGE_STRICT)
    {
        $changedFields = array();

        // Update the changed array with references to changed obj-fields
        foreach ($this->record as $k => $v) {
            // Prevents DBComposite infinite looping on isChanged
            if (is_array($databaseFieldsOnly) && !in_array($k, $databaseFieldsOnly)) {
                continue;
            }
            if (is_object($v) && method_exists($v, 'isChanged') && $v->isChanged()) {
                $this->changed[$k] = self::CHANGE_VALUE;
            }
        }

        // If change was forced, then derive change data from $this->record
        if ($this->changeForced && $changeLevel <= self::CHANGE_STRICT) {
            $changed = array_combine(
                array_keys($this->record),
                array_fill(0, count($this->record), self::CHANGE_STRICT)
            );
            // @todo Find better way to allow versioned to write a new version after forceChange
            unset($changed['Version']);
        } else {
            $changed = $this->changed;
        }

        if (is_array($databaseFieldsOnly)) {
            $fields = array_intersect_key($changed, array_flip($databaseFieldsOnly));
        } elseif ($databaseFieldsOnly) {
            $fieldsSpecs = static::getSchema()->fieldSpecs(static::class);
            $fields = array_intersect_key($changed, $fieldsSpecs);
        } else {
            $fields = $changed;
        }

        // Filter the list to those of a certain change level
        if ($changeLevel > self::CHANGE_STRICT) {
            if ($fields) {
                foreach ($fields as $name => $level) {
                    if ($level < $changeLevel) {
                        unset($fields[$name]);
                    }
                }
            }
        }

        if ($fields) {
            foreach ($fields as $name => $level) {
                $changedFields[$name] = array(
                    'before' => array_key_exists($name, $this->original) ? $this->original[$name] : null,
                    'after' => array_key_exists($name, $this->record) ? $this->record[$name] : null,
                    'level' => $level
                );
            }
        }

        return $changedFields;
    }