General code polish and tweaks.