MOD: code style; Fix: some bugs