Bugfixes

I found a couple of bugs, so I fixed them.