Buggfixes and cleanup of samples.