Many improvements

Check each commit for details.