General refactoring and InfluxDB interface