rework queues with lua and fix py3 compatibility