Limit result set sizes (fix #1068)