refactored lp file format generation, fixes