Implement queue API, needs some test