with additions from dan p, manuel, and moxie