various fixes and improvements based on looking at the smartmeter code
Merge remote-tracking branch 'origin/master'