Fixed some errors and warnings