Fixed exception handling bug and some more stuff.