Fixed bug where device was referenced and the ref count was not
incremented.