Move shared code to a library