rebase of #187

rebase of #187 against master.

@jdmundrawala @danielsdeleo @bwmeier