Fixed some bugs in HEFANROU'S code