Rewritten splitByDelimiter to a functional way, removed mutable objects in process.