Generalize code WIP.