Improved tick count code to include save states