Code review and optimizations
Review and cleanups