src: remove some warnings and do some cleaning

Extracted from the first version of #817