S-expression handling

Not 100% sure this all works, but it seems to. And the tests passed. and I fixed all the bugs I could find