Many small code fixes.