More robust parsing of ps output