OPT: Code optimization and connectivity refactoring