Fix a crasher. Needs testing

Contains the sample.