Small changes in context wrapper
Start refactoring device_query