merge code from crist.

update on 19/9/13-8.50th