Various fixes for the code.