some restructuring
add first draft of generate script