some bugs repaired, -m and -e functionality added