Fixed merge functionality, added hole detection