fix some checked mode exceptions

Fix various exceptions that were occurring in checked mode.

@yjbanov @gaurave