Improve the code quality of ClassWriter.

Also fix a bug in toByteArray() if(hasAsmInsns) ...: type annotations were not reset to null.
4 jobs for improve-class-writer in 10 minutes and 6 seconds (queued for 2 seconds)