Moved CodeWriter to project of its own.
Added flush to codewriter