fixed some bugs in generate_app