Code associated with http://arxiv.org/pdf/1405.7764