Added limits, fixed crashing