Imported from https://github.com/Narp99/FRI_2018