Fix some compiler warnings/bugs