Fixing some serious bugs introduced with the latest commit.