Lately after parked for a few days my '01 330Ci started rough and it usually lasted a couple of minutes. Once it has warmed up a little bit it idled fine and if I drive it everyday it always starts up fine. Based on my research it seems that my battery may be bad, something about the battery having only enough power to start the car but not for everything else (i.e. the car injection system etc). It's probably as old as the car (build date 08/00) and time for a replacement. I bought the car used and in the service receipts that I got from the previous owner I don't see any receipt for battery replacement. Is there anyway or any tool to check the condition of my battery? I have a Bentley manual for E46, I haven't checked but hopefully there's nothing special about changing the battery.

On separate occasions I got the P0171 & P0174 (lean error code) but there's no tear in the intake hose and I haven't checked if the MAF is bad. I will at some point take it off to clean it and see if that helps. Once I cleared the error code at Autozone it went away for a while only to come back after a few weeks/months. Does it mean that I have a bad MAF or is it possibly connected to the starting rough after parked for a few days issue I've been having?

Thanks all.