Move code to lib/