Little bug fixes

Fixed issue with uncaught exception.