Rebase my own modifications on top of Far McKon's;
make it compile with modern compilers.