Fixed bugs in gen_init and added some features