Except as otherwise stated, the code is copyright 2016 Juris Breidaks, Martins Liberts, Janis Jukams