Copied 'toSys' from DESSERT wiki