Some fixes

I had some free time today, so I tried to fix the problems as much as I could. Check it out.