adds sorting to works + general tidy up