Modularising phi lib