Many code improvements.