Fix some errors and warnings