added support for pw-max flag, fixed a few mask bugs, added better
output for status, and various small fixes