Added documentations and cleaned up codes.