Cleaning up logic of the proxy factory by moving closure generation to own private methods