Refs #465. Some fixes based on code review. Thanks Kyle.