More tests passing. Moved some files to a core library.