Refactored generation stuff into modules