Fixing a few minor bugs

Looks like it basically works!