Pulled in fixed and enhancements from Brian's fork