New code based on Mobile Detect, see #3