Rewritten pc code. added pragma to stop it form being optimized.