added a lot of device detection stuff