Minor fixes

Added some checks.