devices refactoring (close #41)