Code Generation and General Improvements