Added the merge file functionality and general bug fixes