First working version with sync, sync might fail on nested constants (of X (foo A)), see README.