works, lots of fixes