Rework: cleanup of code and added feature to change processing order with 'items_first' option