Convert samples
Cleanup of code