System: added some checks to prevent crashes