Refactoring model, adding metadata and m2m log