fix heap merging, add padding and offset adjustment, basic test passes in reverse as well