Fixed CCF in #6, and refactored the code.