Fixed some runtime errors