Various compilation fixes for main firmware