Added hook for before and after file and moved triggerers to places that give more control