It will always fix the wheel whenever it's broken after depositing the paydirt.
Whenever you come with a second inventory and the first hasn't bene processed it will drop 1 paydirt, gets a hammer and fix the sturt and deposits the remaning paydirt.
If it didn't do this in this order restart the client, probably somehting went wrong loading the amount in the sack or whatever.
Also make sure there is no paydirt in the water when you start the script, there is no way of detecting and it could mess up the calculations of when to bank and when to mine.