Learn fixes from Pavel Pimenov
Add missing headers
Fix connection check in OnTimerBase