Code cleanup and planning fix.