Fix a few bugs, move code into std_lib/ directory where possible. Still largely untested.
Add a test