Transfered over old code

Let's see if we can get some working tests.