Cleanup, compacting and optimization part.1.1