Fixes initial port 1.7 NOTE: loads of TODO, feel free to fix