Merged source code from Main Repository, modify according to they changed and also fix compile errors.