Systems over principal ideal domains. A polynomial model approach