Clean up directive code and give each element its own