Drop unused codes. Do some refatoring.