Refactor Masonry-related code and delete unnecessary classes