Renamed z to ns and made quite a few misc tweaks