[fix] common headers are included better
Autodetect function