Ported breakApart() function