Moved device functions to separate file.