Fix some warnings
Fix undefined behavior