Removed unused parts, fixed output file