fix crash-case in LSC::SetUnitNanoPieces + refactor piece-caching code to be more maintainable