This is a partial refactor from change I592c0b1329409307197460cfa8fd69798013f1f8 Change-Id: I8822e68e41c4ebd47eea9ffed4557efc130a7bf7 Co-Authored-By: Andreas Florath <andreas@florath.net>