Refactored device into Lib
Merge branch 'master' into debug
added debug on