Optimization, more modular, misc fixes.