Cleanup, compacting and optimization part.1.6