Corrections taken from Alex branch