Refactor codes

Since the codes are at early stage, I have changed many codes~