[Fix #12] Merge mode code in a single file