Bring general sketch commits upstream

Move the general parts of PR #1178 upstream decrease the maintenance work.
Check include order.