Moved device frame management to its own C file.