A lot of minor changes. This is the first working version!