Added new version of wfgen functions based on: 9cbfe2878ff02102c63d54c8df9948ed7a316f79