Added support for input source detection, appropriate handling.