Made more memory efficient by recycling P matrices & set up timing code