Many fixes, tests now compile and work