Various fixes

This is obviously a dependency for HA to work.