ObjectDef now using foldLeft
FuncM now using foldleft instead of tailrec, fix bug with not appending to accumulator
Refactor replaceEmpty for readability