UI improvement and device detection code