Some improvements, first step towards separate compilation.