Various fixes motivated by improving rebuilding

Sorry for the whitespace noise from my IDE.