Clean up and starting to add clipping function