WP-1009. Restructured.

Cherry-picked from contributor's fork branch wp-1009. Can be merged straightforward.

Jira-issue WP-1009.