added multi-mode support

mode is detected by extension with lib/extmode.js