Fork of mg, reworked to simplify things