fix bugs, better exception messages