Re-organisation and separation into plugin