added new mode, fixed some bugs