Fix some warnings
Improve message handling