Big changes and fixes. Almost complete.