Fixed several bugs so it compiles and runs

There's still work to do.