Several changes to get it fully-ported.