Reduce code complexity by replacing a lot of queue.append/action.set lines with single function calls.