Pavel Karban - update for clang.
Code cleaning.
Handle exceptions in critical sections.
Make set_displacement work for un-setting displacement.