improve and fix enum generation