Lots of fixes, fist working commit.