Big modifications on optimizations module. WIP.