Enhanced code generator and minor drawing fixes