Attempted to refactor CommandQueue, but it seems buggy.