tidy up and small changes for complex sample