Processing code cleanup + refactor