reviewed by kmggh: fixed misc issues.