Fix some warnings and a possible crasher