Split out adapter into its own file

Comment lots of stuff