If he spent so much how come did he have money in the bank at the end of his term.
It's quite simple. Because there was loads of money coming in, due to (mainly) the mining boom and the GST.
An increase in the surplus doesn't automatically mean a cut in spending. It could mean an increase in revenue. And in the mid-2000's, Govt revenues were growing faster than spending increases.