diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 24e30c8..aebaa4c 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -28,6 +28,8 @@
 #include <string>
 
 static constexpr size_t warnAfterErrorCount = 10;
+static constexpr double maxReading = 127;
+static constexpr double minReading = -128;
 
 CPUSensor::CPUSensor(const std::string &path, const std::string &objectType,
                      sdbusplus::asio::object_server &objectServer,
@@ -36,13 +38,11 @@
                      std::vector<thresholds::Threshold> &&_thresholds,
                      const std::string &sensorConfiguration) :
     Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
-           std::move(_thresholds)),
-    objectType(objectType), objServer(objectServer), dbusConnection(conn),
-    configuration(sensorConfiguration),
+           std::move(_thresholds), sensorConfiguration, objectType, maxReading,
+           minReading),
+    objServer(objectServer), dbusConnection(conn),
+    inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0)
 
-    inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0),
-    // todo, get these from config
-    maxValue(127), minValue(-128)
 {
     sensorInterface = objectServer.add_interface(
         "/xyz/openbmc_project/sensors/temperature/" + name,
@@ -163,100 +163,3 @@
 {
     thresholds::checkThresholds(this);
 }
-
-void CPUSensor::updateValue(const double &newValue)
-{
-    // Indicate that it is internal set call
-    internalSet = true;
-    sensorInterface->set_property("Value", newValue);
-    internalSet = false;
-    value = newValue;
-    checkThresholds();
-}
-
-void CPUSensor::setInitialProperties(
-    std::shared_ptr<sdbusplus::asio::connection> &conn)
-{
-    // todo, get max and min from configuration
-    sensorInterface->register_property("MaxValue", maxValue);
-    sensorInterface->register_property("MinValue", minValue);
-    sensorInterface->register_property(
-        "Value", value, [&](const double &newValue, double &oldValue) {
-            return setSensorValue(newValue, oldValue);
-        });
-
-    for (auto &threshold : thresholds)
-    {
-        std::shared_ptr<sdbusplus::asio::dbus_interface> iface;
-        std::string level;
-        std::string alarm;
-        if (threshold.level == thresholds::Level::CRITICAL)
-        {
-            iface = thresholdInterfaceCritical;
-            if (threshold.direction == thresholds::Direction::HIGH)
-            {
-                level = "CriticalHigh";
-                alarm = "CriticalAlarmHigh";
-            }
-            else
-            {
-                level = "CriticalLow";
-                alarm = "CriticalAlarmLow";
-            }
-        }
-        else if (threshold.level == thresholds::Level::WARNING)
-        {
-            iface = thresholdInterfaceWarning;
-            if (threshold.direction == thresholds::Direction::HIGH)
-            {
-                level = "WarningHigh";
-                alarm = "WarningAlarmHigh";
-            }
-            else
-            {
-                level = "WarningLow";
-                alarm = "WarningAlarmLow";
-            }
-        }
-        else
-        {
-            std::cerr << "Unknown threshold level" << threshold.level << "\n";
-            continue;
-        }
-        if (!iface)
-        {
-            std::cout << "trying to set uninitialized interface\n";
-            continue;
-        }
-        if (threshold.writeable)
-        {
-            iface->register_property(
-                level, threshold.value,
-                [&](const double &request, double &oldValue) {
-                    oldValue = request; // todo, just let the config do this?
-                    threshold.value = request;
-                    thresholds::persistThreshold(configuration, objectType,
-                                                 threshold, conn);
-                    return 1;
-                });
-        }
-        else
-        {
-            iface->register_property(level, threshold.value);
-        }
-        iface->register_property(alarm, false);
-    }
-    if (!sensorInterface->initialize())
-    {
-        std::cerr << "error initializing value interface\n";
-    }
-    if (thresholdInterfaceWarning && !thresholdInterfaceWarning->initialize())
-    {
-        std::cerr << "error initializing warning threshold interface\n";
-    }
-
-    if (thresholdInterfaceCritical && !thresholdInterfaceCritical->initialize())
-    {
-        std::cerr << "error initializing critical threshold interface\n";
-    }
-}
