Convert statics to constants

This pr fixes the compile failure with latest `rustc`.

As a bonus, this pr contains fixes for some warnings.