Pushed as 22d11dab8b09d8aed780d5c1086c9e8e5589bc70 to master with minor modifications. -- Oleg