Move stuff into lib