Fix integer overflows and resulting crashes when canvas is zoomed out to ridiculous proportions