More fixes and code improvements.