got most things working, writing tests and such