Refactor directive and add diary package