(maint) Tidy up puppet code and fix initial bugs