First pass and adding two-stage predictor (major refactor involved)