Fixed some errors and a lot of warnings