It lists the folder for available store files, then it checks them sequentially until it finds one that is under the maximum size threshold. If no such store is found, new one is created. Maximum store size threshold is 3.7 GB.
Can including it in the modRana package once it's done ? - Only if you don't mind, of course. This way it could be placed in /usr/bin and would be easily callable as it would be in $PATH.
I hit something similar - the solution was not to commit after every tile but just once every 50 or so tiles. This made the process quite faster IIRC.