Work on #258

This is a bunch of work that should go toward #258. It is not finished yet but here we go

# DO NOT MERGE IT YET
must be implemented before merge