It should be harder to crash now.
Some more edge case handling.