Chemical bonding and structure in layered transition metal dichalcogenides