added checks and safeguards for limits
more safe guards; preventing crashes