Cleaned up version. Will transition into using device primitives in order to be licensing conform.