Writing rules

Work in progress...