Some more refactoring on Stage 3 and added skeleton for Stage 4