A few fixes. Sample still needs improvements