Initial commit, ported from existing working solution.