Fix a few possible errors and warnings