More bugfixes (I've really learned a lot since I wrote this program...)