Import initial proffit code
Various fixes and enhancements