To keep pests out of stored rice...we use Double Bubble bubble gum. You do need to store you rice in an airtight container. Buy the gum in a large bag, unwrap it, and toss the pieces into the rice container. Just watch for it so that it doesn't end up in your dinner. I don't know why it works, it just does. I've never had bugs.
The best way to use the bayleaf for flour, is to get a sandwich size plastic bag and make some holes in it with a hole punch or a fork on one side, fill the bag with bayleaf, and tape it to the inside lid of the airtight container that you are using for storage, with the holes facing the flour. Flour needs to be stored in a temperature controlled room, or it will turn.
You can also toss a couple of handfuls of bayleaf on the shelves of your pantry to keep pests out.